import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  HomeList({Key? key}) : super(key: key);

  List notifyList = [
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
  ];
//头部结构
  List<Widget> getTitleList() {
    return [
      Image.network(
          'https://tse4-mm.cn.bing.net/th/id/OIP-C.xzJw3A0BQf-hySk7ablf4AHaHa?w=208&h=208&c=7&r=0&o=7&dpr=1.3&pid=1.7&rm=3',
          width: 25),
      const Text('社区',
          style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
      const Text('公告',
          style: TextStyle(
              fontSize: 16, fontWeight: FontWeight.bold, color: Colors.orange)),
    ];
  }

//底部列表结构
  List<Widget> getBottomList() {
    return notifyList.map((item) {
      return Column(
        children: [
          Padding(
            padding: const EdgeInsets.all(8),
            child: Container(
                height: 120,
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(12),
                ),
                margin: const EdgeInsets.only(top: 10),
                child: Padding(
                  padding: const EdgeInsets.only(left: 12.0),
                  child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Row(
                          children: [
                            Text(item['title']),
                            const Spacer(),
                          ],
                        ),
                        const SizedBox(height: 5),
                        Text(item['content']),
                        Text(item['createdAt'])
                      ]),
                )),
          ),
        ],
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(top: 10),
      child: Column(
        children: [
          Row(
            children: getTitleList(),
          ),
          ListView(
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            children: getBottomList(),
          )
        ],
      ),
    );
  }
}
